﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Web;

/// <summary>
/// Paths to different files
/// </summary>
public static class Paths
{
	public const string admin_index = "index.aspx";
    public const string admin_logout = "logout.aspx";
    public const string admin_edit_model = "edit_model.aspx";

    public const string admin_to_serverRoot = "../../";    

    //User controls
    public const string admin_uc_loginControl = "UserControls/LoginControl.ascx";
    public const string admin_uc_createCredentials = "UserControls/CreateCredentials.ascx";
    public const string admin_uc_loggedin = "UserControls/LoggedIn.ascx";
    public const string admin_uc_modelHandler = "Usercontrols/ModelEditHandler.ascx";
    /// <summary>
    /// Models folder, relative from root
    /// </summary>
    public const string ModelsFolder_relative = "Models/";
    /// <summary>
    /// Thumbnails folder, relative from root
    /// </summary>
    public const string ThumbnailsFolder_relative = ModelsFolder_relative + "Thumbnails/";


    public static string serverBase = "";
    public static string serverRoot;

    /// <summary>
    /// The modellist file
    /// </summary>
    public static string modellist;
    /// <summary>
    /// The location of the temporary modellist file
    /// </summary>
    public static string modellist_temp;
    /// <summary>
    /// Temporary model when converting to new fileformat
    /// </summary>
    public static string model_temp;
    /// <summary>
    /// The path to where textures are stored
    /// </summary>
    public static string texturesFolder;
    /// <summary>
    /// Path to folder where models are, absolute server path
    /// </summary>
    public static string modelsFolder;
    /// <summary>
    /// Thumbnails folder, absolute server path
    /// </summary>
    public static string thumbnailFolder;
    //The folder path to c++ applications folder
    public static string admin_cpp_folder;

    public static string admin_cpp_converterFile;

    private static bool m_intilized = false;
    
    public static void SetServerPaths(HttpServerUtility a_server)
    {
        if (!m_intilized)
        {
            m_intilized = true;
            //Seems Server.MapPath is relative from file calling it instead of root       
            serverRoot = a_server.MapPath("~") + "/";
            serverBase = serverRoot + "admin/asp/";

            admin_cpp_folder = serverRoot + "admin/cpp/";
            admin_cpp_converterFile = admin_cpp_folder + "GorbatrasConverter.exe";

            texturesFolder = serverRoot + "Textures/";
            modelsFolder = serverRoot + ModelsFolder_relative;
            thumbnailFolder = serverRoot + ModelsFolder_relative + "Thumbnails/";

            modellist = modelsFolder + "Models.txt";
            modellist_temp = modelsFolder + "temp_Models.txt";

            model_temp = modelsFolder + "temp_model";

            LoginHandler.SetPaths();            
        }        
    }
}